package com.bw.gmall.app.dws;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

public class IKTest {

    public static void main(String[] args) {
        List<String> ik = ik("回杭八味大叔级");
        System.out.println(ik);
    }

    public static List<String> ik(String str){
        List<String> list = new ArrayList<>();
        StringReader stringReader = new StringReader(str);
        IKSegmenter ik = new IKSegmenter(stringReader, true);
        try {
            Lexeme next = ik.next();
            while (next!=null){
                String lexemeText = next.getLexemeText();
                list.add(lexemeText);
                next = ik.next();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        return list;
    }
}
